package com.ruoyi.project.dataviewSystem.service.impl;

import java.util.List;

import com.ruoyi.framework.config.ServerConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.dataviewSystem.mapper.SurveillancePictureMapper;
import com.ruoyi.project.dataviewSystem.domain.SurveillancePicture;
import com.ruoyi.project.dataviewSystem.service.ISurveillancePictureService;

/**
 * 监控图片Service业务层处理
 * 
 * @author wangshuo
 * @date 2021-01-31
 */
@Service
public class SurveillancePictureServiceImpl implements ISurveillancePictureService 
{
    @Autowired
    private SurveillancePictureMapper surveillancePictureMapper;
    @Autowired
    private ServerConfig serverConfig;

    /**
     * 查询监控图片
     * 
     * @param id 监控图片ID
     * @return 监控图片
     */
    @Override
    public SurveillancePicture selectSurveillancePictureById(Long id)
    {
        return surveillancePictureMapper.selectSurveillancePictureById(id);
    }

    /**
     * 查询监控图片列表
     * 
     * @param surveillancePicture 监控图片
     * @return 监控图片
     */
    @Override
    public List<SurveillancePicture> selectSurveillancePictureList(SurveillancePicture surveillancePicture)
    {
        if(surveillancePicture.getPictureType()==0){
            surveillancePicture.setPictureType(null);
        }
        List<SurveillancePicture> surveillancePictures = surveillancePictureMapper.selectSurveillancePictureList(surveillancePicture);
        surveillancePictures.forEach(x->{
//            x.setUrl(serverConfig.getUrl()+x.getUrl());
            x.setUrl("http://121.37.31.192:19091"+x.getUrl());
        });
        return surveillancePictures;
    }

    /**
     * 新增监控图片
     * 
     * @param surveillancePicture 监控图片
     * @return 结果
     */
    @Override
    public int insertSurveillancePicture(SurveillancePicture surveillancePicture)
    {
        return surveillancePictureMapper.insertSurveillancePicture(surveillancePicture);
    }

    /**
     * 修改监控图片
     * 
     * @param surveillancePicture 监控图片
     * @return 结果
     */
    @Override
    public int updateSurveillancePicture(SurveillancePicture surveillancePicture)
    {
        return surveillancePictureMapper.updateSurveillancePicture(surveillancePicture);
    }

    /**
     * 批量删除监控图片
     * 
     * @param ids 需要删除的监控图片ID
     * @return 结果
     */
    @Override
    public int deleteSurveillancePictureByIds(Long[] ids)
    {
        return surveillancePictureMapper.deleteSurveillancePictureByIds(ids);
    }

    /**
     * 删除监控图片信息
     * 
     * @param id 监控图片ID
     * @return 结果
     */
    @Override
    public int deleteSurveillancePictureById(Long id)
    {
        return surveillancePictureMapper.deleteSurveillancePictureById(id);
    }

    @Override
    public int batchInsert(List<SurveillancePicture> surveillancePictures) {
        return surveillancePictureMapper.batchInsert(surveillancePictures);
    }

    @Override
    public List<String> getAllPicUrl(SurveillancePicture surveillancePicture) {
        return surveillancePictureMapper.getAllPicUrl(surveillancePicture);
    }
}
